<?php
	####################################################
	# library import and object instance.              #
	####################################################
	# 커먼 인클루드
	include_once( '../common.php' );

	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	//$req = $_REQUEST;

	//$req = Request::clean_request($_REQUEST, 1);

	# GET(url variables)

	# POST(form variables)
	$pmode = Request::clean_individual($_POST['mode']);
	$preturl = Request::clean_individual($_POST['returl']);
	//Nlog::puts('pmode',$pmode);
	//Nlog::puts('preturl',$preturl);


	# Validation(special case validate)
	//*/
	Validation::check_is_emptys($pmode);
	Validation::check_is_emptys($preturl);
	//*/
	####################################################
	# implementation                                   #
	####################################################
	$sec->individual_access();

	switch($pmode) {
		case "modify":
			$pmap = Request::dic($_POST['map'], 'cuid');
			$cnt = $appm->modify_categories($pmap);
			//Nlog::puts('pmap', $pmap);
		break;

		case "create":
			$pmap = Request::clean_request($_POST['map']);
			$cnt = $appm->create_categories($pmap);
			//Nlog::puts('pmap', $pmap);
		break;

		case "delete":
			$pmap = Request::dic($_POST['map'], 'cuid');
			$cnt = $appm->delete_categories($pmap);
			//Nlog::puts('pmap', $pmap);
		break;

		case "linkage":
			$pmap = Request::clean_request($_POST['map']);
			$pcuid = Request::clean_individual($_POST['cuid']);
			//Nlog::puts('pmap', $pmap);
			//Nlog::puts('pcuid', $pcuid);
			$cntarr = $appm->linkage_modules($pcuid, $pmap);
		break;
		default : break;
	} //endswitch


?>
<?php
	# HTML START
	echo $html->custom_header(TITLE);
	echo $tplt->page_construct_javascript();
	echo $html->custom_js("{$JS}common.js");
	echo $html->custom_css("{$CSS}common.css");
	echo $html->custom_body();
?>
	<?php $tplt->app_head($NAVI)?>
	<?php $tplt->tiles_admin_sidebar($NAVI)?>
	<?php $tplt->tiles_admin_contents($pkname, $pname, $pdesc)?>


	<div class="msgbox">
		<p>
			<?php switch($pmode) :

				case "modify" : ?>
					<strong>카테고리 정보 수정 내역</strong><br />
					<?=$cnt?>개의 카테고리 정보가 수정 되었습니다.
				<?php break; ?>

				<?php case "create" : ?>
					<strong>카테고리 추가 내역</strong><br />
					<?=$cnt?>개의 카테고리가 추가 되었습니다.
				<?php break; ?>

				<?php case "delete" : ?>
					<strong>카테고리 삭제 내역</strong><br />
					<?=$cnt?>개의 카테고리가 삭제 되었습니다.
				<?php break; ?>

				<?php case "linkage" : ?>
					<strong>모듈 연결 내역</strong><br />
					<?=$cntarr['cnt1']?>개의 모듈은 변경사항이 없습니다.<br />
					<?=$cntarr['cnt2']?>개의 모듈이 카테고리에 연결 되었습니다.<br />
					<?=$cntarr['cnt3']?>개의 모듈은 카테고리에서 연결 해제 되었습니다.<br />
				<?php break; ?>

				<?php default : break; ?>
			<?php endswitch; ?>
		</p>
	</div>
	<?php switch($pmode) :
		case "linkage" : ?>
			<span class="cbtn_xl mart5" onclick="Mover.href('admin.categories.manager');">매니저로 이동</span>
		<?php break; ?>
		<?php default : break; ?>
	<?php endswitch; ?>
			<span class="cbtn_s mart5" onclick="Mover.href('<?=$preturl?>');">확인</span>


<?php
	# HTML END
	echo $tplt->tiles_admin_footer();
	echo $tplt->page_destruct_javascript();
	include_once( '../endproc.php' );
	echo $html->html_footer();
?>